import requests;
from lxml import etree;

baidu=requests.get('https://www.baidu.com');
baidu.encoding='utf-8';#不加这行，会有乱码
html=etree.HTML(baidu.text);
news_title=html.xpath('//*[@id="u1"]/a[1]/text()')[0];
news_url=html.xpath('//*[@id="u1"]/a[1]/@href')[0];
print(news_title);
print(news_url);